﻿/*menu*/
var persistmenu = "yes"
var persisttype = "sitewide"

function SwitchMenu(obj) {
    if (document.getElementById) {
        var el = document.getElementById(obj);
        if (typeof (el) != undefined && el != null) {
            var ar = document.getElementById("masterdiv").getElementsByTagName("span");
            if (el.style.display != "block") {
                for (var i = 0; i < ar.length; i++) {
                    if (ar[i].className == "submenu")
                        ar[i].style.display = "none";
                }
                el.style.display = "block";
            } else {
                el.style.display = "none";
            }
        }
    }
}

//function get_cookie(Name) {
//    var search = Name + "="
//    var returnvalue = "";
//    if (document.cookie.length > 0) {
//        offset = document.cookie.indexOf(search)
//        if (offset != -1) {
//            offset += search.length
//            end = document.cookie.indexOf(";", offset);
//            if (end == -1) end = document.cookie.length;
//            returnvalue = unescape(document.cookie.substring(offset, end))
//        }
//    }
//    return returnvalue;
//}

//function onloadfunction() {
//    if (persistmenu == "yes") {
//        var cookiename = (persisttype == "sitewide") ? "switchmenu" : window.location.pathname
//        var cookievalue = get_cookie(cookiename)
//        if (cookievalue != "")
//            document.getElementById(cookievalue).style.display = "block"
//    }
//}

//function savemenustate() {
//    var inc = 1, blockid = ""
//    while (document.getElementById("sub" + inc)) {
//        if (document.getElementById("sub" + inc).style.display == "block") {
//            blockid = "sub" + inc
//            break
//        }
//        inc++
//    }
//    var cookiename = (persisttype == "sitewide") ? "switchmenu" : window.location.pathname
//    var cookievalue = (persisttype == "sitewide") ? blockid + ";path=/" : blockid
//    document.cookie = cookiename + "=" + cookievalue
//}

/*het menu    */
/*parsing querystring*/
function Querystring(qs) { // optionally pass a querystring to parse
    this.params = {};

    if (qs == null) qs = location.search.substring(1, location.search.length);
    if (qs.length == 0) return;

    // Turn <plus> back to <space>
    // See: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4.1
    qs = qs.replace(/\+/g, ' ');
    var args = qs.split('&'); // parse out name/value pairs separated via &

    // split out each name=value pair
    for (var i = 0; i < args.length; i++) {
        var pair = args[i].split('=');
        var name = decodeURIComponent(pair[0]);

        var value = (pair.length == 2)
			? decodeURIComponent(pair[1])
			: name;

        this.params[name] = value;
    }
}

Querystring.prototype.get = function(key, default_) {
    var value = this.params[key];
    return (value != null) ? value : default_;
}

Querystring.prototype.contains = function(key) {
    var value = this.params[key];
    return (value != null);
}
/*parsing querystring*/

$(document).ready(function() {
    var qs = new Querystring(); //--> use this for not url rewrite
    var xeID = qs.get("xe", ""); //--> use this for not url rewrite
    
    /*use this for url rewrite*/
    //var currentUrl = document.location.href;
    //var indexOfXe = currentUrl.indexOf("/xe/");
    //var indexOfLastSlash = currentUrl.lastIndexOf("/");
    //var xeID = currentUrl.substring(indexOfXe + 4, indexOfLastSlash);
    /*end use this for url rewrite*/
    
  
   
    //active menu

    jQuery('.submenu a[href=/xe/' + xeID + ']').addClass('active');
    jQuery('.submenu').has('a.active').css('display', 'block');
});

